package com.xinqi.modules.prepare.prepare.manager;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xinqi.common.mybatis.data.service.BaseService;
import com.xinqi.modules.prepare.prepare.domain.PrepareEntity;
import com.xinqi.modules.prepare.prepare.dto.req.PrepareQueryDTO;
import com.xinqi.modules.prepare.prepare.dto.rsp.PrepareResultDTO;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 备课区管理层
 *
 * @author: system
 * @date: 2023/03/19
 */
public interface PrepareManager extends BaseService<PrepareEntity> {

    /**
     * 自定义分页查询
     */
    Page<PrepareResultDTO> findPage(Page<Object> page, PrepareQueryDTO query);

    /**
     * 自定义列表查询
     */
    List<PrepareResultDTO> findList(PrepareQueryDTO query);

    /**
     * 根据id查询 备课区数据
     */
    PrepareEntity findById(Long id);

    /**
     * 根据id删除 备课区数据
     */
    @Transactional(rollbackFor = Exception.class)
    boolean deleteById(Long id);

    /**
     * 校验当前用户的备课区名称是否已存在
     */
    boolean isExistName(Long userId, String name, Long oldId);

    boolean isExistDefault(Long userId);

    @Transactional(rollbackFor = Exception.class)
    Long insertDefault(Long entity);

    Long prepareCount(Long userId);

    Long prepareCount(Long userId, Boolean isDefault);
}
